package com.intelligent.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.intelligent.utils.Result;
import com.intelligent.dto.InventoryCheckAddDTO;
import com.intelligent.dto.InventoryCheckQueryDTO;
import com.intelligent.service.InventoryCheckService;
import com.intelligent.vo.InventoryCheckVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/inventory-check")
@Api(tags = "库存盘点管理")
public class InventoryCheckController {

    @Autowired
    private InventoryCheckService inventoryCheckService;

    @PostMapping("/page")
    @ApiOperation("分页查询库存盘点记录")
    public Result<IPage<InventoryCheckVO>> page(InventoryCheckQueryDTO query) {
        IPage<InventoryCheckVO> page = inventoryCheckService.pageList(query);
        return Result.success(page);
    }

    @PostMapping("/add")
    @ApiOperation("新增库存盘点记录")
    public Result<Boolean> add(@RequestBody InventoryCheckAddDTO addDTO) {
        boolean result = inventoryCheckService.add(addDTO);
        return result ? Result.success() : Result.error("新增库存盘点记录失败");
    }
}
